package com.example.demo.demos.web.controller;

import com.example.demo.demos.web.domain.Classmate;
import com.example.demo.demos.web.service.ClassmateService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/classmate")
public class ClassmateController {
    @Resource
    private ClassmateService classmateService;


    @PostMapping
    public int addClassmate(@RequestBody Classmate classmate) {
        return classmateService.addClassmate(classmate);
    }


    @DeleteMapping("/{xuehao}")
    public int deleteClassmateByXuehao(@PathVariable int xuehao) {
        return classmateService.deleteClassmateByXuehao(xuehao);
    }


    @PutMapping
    public int updateClassmate(@RequestBody Classmate classmate) {
        return classmateService.updateClassmate(classmate);
    }


    @GetMapping("/{xuehao}")
    public Classmate getClassmateByXuehao(@PathVariable int xuehao) {
        return classmateService.getClassmateByXuehao(xuehao);
    }
}
